<template>
  <el-container>
    <el-header>
      <el-row class="mt20" type="flex" justify="center">
        <el-col :span="10">
          <el-input v-model="num" placeholder="请输入内容"></el-input>
        </el-col>
        <el-col :span="6">
          <el-button type="info" @click.native="getPhone(num)"><i class="iconfont icon-ziyuan9"></i> search</el-button>
        </el-col>
      </el-row>


    </el-header>
    <el-main>
      <el-card class="box-card mt20">
        <div v-for="article in articles" class="text item">
          {{article.title}}
        </div>
      </el-card>
      <!--<el-row class="mt20">
        <el-col :span="6" v-for="(o, index) in 6" :offset="index%3 !== 0 ? 2 : 0">
          <el-card :body-style="{ padding: '0px' }">
            <img src="../../assets/images/logo.png" class="image">
            <div style="padding: 14px;">
              <span>好吃的汉堡</span>
              <div class="mt20 clearfix">
                <time class="time">{{ currentDate | dateFormats}}</time>
                <el-button type="text" class="button">操作按钮</el-button>
              </div>
            </div>
          </el-card>
        </el-col>
      </el-row>-->
      <el-form ref="form" :model="form" label-width="80px" class="mt20">
        <el-form-item label="活动名称">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="活动区域">
          <el-select v-model="form.region" placeholder="请选择活动区域">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="活动时间">
          <el-col :span="11">
            <el-date-picker type="date" placeholder="选择日期" v-model="form.date1" style="width: 100%;"></el-date-picker>
          </el-col>
          <el-col class="line" :span="2">-</el-col>
          <el-col :span="11">
            <el-time-picker type="fixed-time" placeholder="选择时间" v-model="form.date2" style="width: 100%;"></el-time-picker>
          </el-col>
        </el-form-item>
        <el-form-item label="即时配送">
          <el-switch v-model="form.delivery"></el-switch>
        </el-form-item>
        <el-form-item label="活动性质">
          <el-checkbox-group v-model="form.type">
            <el-checkbox label="美食/餐厅线上活动" name="type"></el-checkbox>
            <el-checkbox label="地推活动" name="type"></el-checkbox>
            <el-checkbox label="线下主题活动" name="type"></el-checkbox>
            <el-checkbox label="单纯品牌曝光" name="type"></el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="特殊资源">
          <el-radio-group v-model="form.resource">
            <el-radio label="线上品牌商赞助"></el-radio>
            <el-radio label="线下场地免费"></el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="活动形式">
          <el-input type="textarea" v-model="form.desc"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">立即创建</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
    </el-main>
    <el-footer>
      <el-button type="info" @click.native="turnToList">返回列表</el-button>
    </el-footer>
  </el-container>
</template>
<script>
  export default {
    data () {
      return {
        articles: [],
        num: '',
        phoneList: [],
        form: {
          name: '',
          region: '',
          date1: '',
          date2: '',
          delivery: false,
          type: [],
          resource: '',
          desc: ''
        },
        currentDate: new Date()
      }
    },
    mounted () {
      this.fuc()
    },
    methods: {
      onSubmit () {
        console.log('submit!')
      },
      fuc () {
        this.$http.jsonp('https://api.douban.com/v2/movie/top250?count=10', {}, {
          headers: {},
          emulateJSON: true
        }).then(function (response) {
          if (!this.$utils.isEmptyObject(response)) {
            // 这里是处理正确的回调
            this.articles = response.data.subjects
            // this.articles = response.data["subjects"] 也可以
          }
        }).catch((e) => {
          console.error('错误', e)
        })
      },
      getPhone (val) {
        console.log(val)
      },
      turnToList () {
        this.$router.push({
          name: 'list'
        })
      }
    }
  }
</script>

<style>
  .mt20{
    margin-top: 20px;
  }
  .el-input__inner{
    width: 100%;
  }
  .time {
    font-size: 13px;
    color: #999;
  }

  .button {
    padding: 0;
    float: right;
  }

  .image {
    width: 100%;
    display: block;
  }
</style>
